package cn.lanqiao.web.controller;

import cn.lanqiao.common.utile.Result;
import cn.lanqiao.common.vo.ArrangementVO;
import cn.lanqiao.system.service.ArrangementService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.management.relation.RelationSupport;
import java.util.List;

@RestController
@RequestMapping("/arrangement")
@CrossOrigin
public class ArrangementController{
    @Autowired
    private ArrangementService arrangementService;
    @RequestMapping("/findFilmId")
    public Result findByFilmId(@Param("id") Integer id){
        System.out.println("接收到的filmID："+id);
        try {
            ArrangementVO arrangementVO=arrangementService.findByFilmId(id);
            return Result.ok(arrangementVO);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail("系统错误!");
    }
    //获取座位情况
    @RequestMapping("/getSeat")
    public Result getSeat(Integer id){
        System.out.println("收到的场次id:"+id);
        try {
           List<Integer> seatList=arrangementService.getSeatsHaveSelected(id);
           return Result.ok(seatList);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail("系统错误!");
    }
}
